package org.liao.springboot.webservice.ws.service;

import javax.xml.ws.Endpoint;

import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


//todo https://gitee.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/spring_boot/src/main/java/sample/rs/service/SampleRestApplication.java
@Configuration
public class WSWebServerConfig {

    @Autowired
    private Bus bus;
    @Autowired
    private WeatherInterFace weatherInterFace;
    @Bean
    public ServletRegistrationBean dispatcherServletAdr(){
        return new ServletRegistrationBean(new CXFServlet(),"/*");
    }
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, weatherInterFace);
        endpoint.publish("/weather");
        return endpoint;
    }
}
